package com.sx.gongzhong.pest;

import com.sx.gongzhong.model.HeadParamBean;
import com.sx.gongzhong.model.ReplyUserBean;
import com.sx.gongzhong.net.ApiManager;
import com.sx.gongzhong.net.BaseCallBack;
import com.sx.gongzhong.view.IVoidView;

import java.util.Map;

/**
 * Created by admin on 2018/1/8.
 * 举报/禁言
 */

public class ReportAndForbiddenPest {

    private IVoidView voidView;
    public ReportAndForbiddenPest(IVoidView voidView) {
        this.voidView = voidView;
    }

    /**
     * 举报
     * @param reportTypeID 举报类型id
     * @param columnType  举报模块
     * @param dataId 数据id
     */
    public void report(String reportTypeID,String columnType,String dataId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("reportType.id",reportTypeID);
        map.put("columnType",columnType);
        map.put("reportDataId",dataId);
        new ApiManager().report(map, new BaseCallBack<ReplyUserBean.BaseResult<Void>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Void> response) {
                voidView.voidView("举报成功");
            }
            @Override
            public void onFailures(String message) {
                if (message.equals("用户已被禁言")){
                    voidView.showError("你被举报，已禁言");
                }else {
                    voidView.showError(message);
                }
            }
        });
    }

    /**
     * 禁言
     *  forbiddenTypeId 禁言类型
     * columnType      禁言的栏目模块类型
     * forbiddenUserId 被禁言禁言的数据ID
     */
    public void addForbidden(String forbiddenTypeId,String columnType,String columnDataId) {
        Map<String,Object> map = HeadParamBean.getHead();
        map.put("forbiddenType.id",forbiddenTypeId);
        map.put("columnType",columnType);
        map.put("columnDataId",columnDataId);
        new ApiManager().addForbidden(map, new BaseCallBack<ReplyUserBean.BaseResult<Void>>() {
            @Override
            public void onSuccess(ReplyUserBean.BaseResult<Void> response) {
                voidView.voidView("禁言成功");
            }
            @Override
            public void onFailures(String message) {
                voidView.showError(message);
            }
        });
    }
}
